package cn.com.guage.guc.collection.safe;

import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

public class ConcurrentHashMapSafeTest {

	public static void main(String[] args) {
		
	//	Map<String, String> map = new HashMap<>();
		Map<String, String> map = new ConcurrentHashMap<>();
		for (int i = 0; i < 10; i++) {
			String key = String.valueOf(i);
			new Thread(() -> {
				// 向集合添加内容
				map.put(key, UUID.randomUUID().toString().substring(0, 8));
				// 从集合获取内容
				System.out.println(map);
			}, String.valueOf(i)).start();
		}
	}

}
